package day02;

public class DataTypeDemo {

    public static void main(String[] args) {
        //类型间的转换
        byte b1 = 5;
        byte b2 = 6;
        byte b3 = (byte) (b1 + b2);
        


        /*
        //转换类型
        int a =5;
        long b=a;
        int c= (int) b;

        long d=5;
        double e =5;
        System.out.println(e);
        long f =10000000000l;
        int g=(int) f;
        System.out.println(g);//14100648,强转有可能发生溢出
        double h=25.236;
        int i=(int) h;
        System.out.println(i);//25,强转有可能丢失精度

         */


        /*
        //char:字符型,2个字节
        char c1 = '女';
        char c2 = 'f';
        char c3 = '6';
        char c4 = ' ';
        //char c5='';//编译错误,必须有字符
        // char c6=女;//编译错误
        //char c7 ='10' //编译错误 ,知能装一个字符
        char c8 = 65534;
        char c9 = '\'';   //'\'转义符
        char c10 = '\\';
        System.out.println(c9 + "    " + c10);

         */


        /*
//        boolean:布尔型,1个字节
        boolean a=true;
        boolean b=false;
        //boolean c= 25;  //编译错误,布尔类型只能存储true和false

         */

        /*
        //double:浮点型,8个字节,无限大
        double a =25.365;
        float b=25.534f;
        double c=3.0,d=2.9;
        System.out.println(c-d);

         */

        /*
        //long长整型,8个字节,-900万万多亿到90万万亿多
        long a = 25L;//25L为长整型直接量
        //long b =10000000000;
        long c = 100000000000L;
        long d = 365L * 24 * 60 * 60 * 1000;
        System.out.println(d);

        long e = 1000000000 * 2 * 10L;
        System.out.println(e);
        long f = 1000000000 * 3 * 10L;//溢出
        System.out.println(f);
        long g = 1000000000L * 3 * 10;
        System.out.println(g);

         */

        /*
        int整型,4个字节,-21亿多到21亿多
         int a=250;
         //int b= 10000000000;
         //int c =25.689;//编译错误 ,整型变量中只能装整数
        System.out.println(5/2);
        System.out.println(2/5);
        System.out.println(5/2.0);

        int d=2147483647;
        d=d+1;
        System.out.println(d);//发生了溢出

         */

    }
}
